<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template partial_date</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp" title="Header &lt;boost/date_time/date_generators.hpp&gt;">
<link rel="prev" href="year_based_generator.html" title="Class template year_based_generator">
<link rel="next" href="nth_kday_of_month.html" title="Class template nth_kday_of_month">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="year_based_generator.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="nth_kday_of_month.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.date_time.partial_date"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template partial_date</span></h2>
<p>boost::date_time::partial_date &#8212; Generates a date by applying the year to the given month and day. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp" title="Header &lt;boost/date_time/date_generators.hpp&gt;">boost/date_time/date_generators.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> date_type<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">:</span>
  <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">date_time</span><span class="special">::</span><span class="identifier">year_based_generator</span><span class="special">&lt;</span> <span class="identifier">date_type</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">calendar_type</span>    <a name="boost.date_time.partial_date.calendar_type"></a><span class="identifier">calendar_type</span><span class="special">;</span>
  <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">day_type</span>     <a name="boost.date_time.partial_date.day_type"></a><span class="identifier">day_type</span><span class="special">;</span>     
  <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">month_type</span>   <a name="boost.date_time.partial_date.month_type"></a><span class="identifier">month_type</span><span class="special">;</span>   
  <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">year_type</span>    <a name="boost.date_time.partial_date.year_type"></a><span class="identifier">year_type</span><span class="special">;</span>    
  <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">duration_type</span>    <a name="boost.date_time.partial_date.duration_type"></a><span class="identifier">duration_type</span><span class="special">;</span>
  <span class="keyword">typedef</span> <span class="identifier">duration_type</span><span class="special">::</span><span class="identifier">duration_rep</span> <a name="boost.date_time.partial_date.duration_rep"></a><span class="identifier">duration_rep</span><span class="special">;</span> 

  <span class="comment">// <a class="link" href="partial_date.html#boost.date_time.partial_dateconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="partial_date.html#idp18530624-bb"><span class="identifier">partial_date</span></a><span class="special">(</span><span class="identifier">day_type</span><span class="special">,</span> <span class="identifier">month_type</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="partial_date.html#idp27944784-bb"><span class="identifier">partial_date</span></a><span class="special">(</span><span class="identifier">duration_rep</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="partial_date.html#idp28781792-bb">public member functions</a></span>
  <span class="identifier">date_type</span> <a class="link" href="partial_date.html#idp28782000-bb"><span class="identifier">get_date</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">date_type</span> <a class="link" href="partial_date.html#idp30237296-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="partial_date.html#idp28791744-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="partial_date.html#idp41398480-bb"><span class="keyword">operator</span><span class="special">&lt;</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">month_type</span> <a class="link" href="partial_date.html#idp29066368-bb"><span class="identifier">month</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">day_type</span> <a class="link" href="partial_date.html#idp29624864-bb"><span class="identifier">day</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="partial_date.html#idp29625312-bb"><span class="identifier">to_string</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp48527504"></a><h2>Description</h2>
<p>Example usage: </p>
<pre class="programlisting">    <span class="identifier">partial_date</span> <span class="identifier">pd</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">Jan</span><span class="special">)</span><span class="special">;</span>
    <span class="identifier">partial_date</span> <span class="identifier">pd2</span><span class="special">(</span><span class="number">70</span><span class="special">)</span><span class="special">;</span>
    <span class="identifier">date</span> <span class="identifier">d</span> <span class="special">=</span> <span class="identifier">pd</span><span class="special">.</span><span class="identifier">get_date</span><span class="special">(</span><span class="number">2002</span><span class="special">)</span><span class="special">;</span> <span class="comment">//2002-Jan-01</span>
    <span class="identifier">date</span> <span class="identifier">d2</span> <span class="special">=</span> <span class="identifier">pd2</span><span class="special">.</span><span class="identifier">get_date</span><span class="special">(</span><span class="number">2002</span><span class="special">)</span><span class="special">;</span> <span class="comment">//2002-Mar-10</span>
</pre>
<p> </p>
<div class="refsect2">
<a name="idp48538640"></a><h3>
<a name="boost.date_time.partial_dateconstruct-copy-destruct"></a><code class="computeroutput">partial_date</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><a name="idp18530624-bb"></a><span class="identifier">partial_date</span><span class="special">(</span><span class="identifier">day_type</span> d<span class="special">,</span> <span class="identifier">month_type</span> m<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><a name="idp27944784-bb"></a><span class="identifier">partial_date</span><span class="special">(</span><span class="identifier">duration_rep</span> days<span class="special">)</span><span class="special">;</span></pre>Partial date created from number of days into year. Range 1-366. <p>Allowable values range from 1 to 366. 1=Jan1, 366=Dec31. If argument exceeds range, <code class="computeroutput"><a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a></code> will be created with closest in-range value. 60 will always be Feb29, if get_date() is called with a non-leap year an exception will be thrown </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp48545856"></a><h3>
<a name="idp28781792-bb"></a><code class="computeroutput">partial_date</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">date_type</span> <a name="idp28782000-bb"></a><span class="identifier">get_date</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return a concrete date when provided with a year specific year. <p>Will throw an 'invalid_argument' exception if a <code class="computeroutput"><a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a></code> object, instantiated with Feb-29, has get_date called with a non-leap year. Example: </p>
<pre class="programlisting"> partial_date pd(29, Feb);
 pd.get_date(2003); // throws invalid_argument exception
 pg.get_date(2000); // returns 2000-2-29
</pre>
<p> </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="identifier">date_type</span> <a name="idp30237296-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idp28791744-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&amp;</span> rhs<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idp41398480-bb"></a><span class="keyword">operator</span><span class="special">&lt;</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&amp;</span> rhs<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">month_type</span> <a name="idp29066368-bb"></a><span class="identifier">month</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">day_type</span> <a name="idp29624864-bb"></a><span class="identifier">day</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="idp29625312-bb"></a><span class="identifier">to_string</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns string suitable for use in POSIX time zone string. <p>Returns string formatted with up to 3 digits: Jan-01 == "0" Feb-29 == "58" Dec-31 == "365" </p>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="year_based_generator.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="nth_kday_of_month.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
